package com.atelier.plugin.pjavafx;

import com.intellij.ide.util.PackageChooserDialog;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiPackage;
import com.intellij.ui.components.JBPanel;

import javax.swing.*;
import java.io.File;

public class MyPackageChooserDialog extends AnAction {

    @Override
    public void actionPerformed(AnActionEvent e) {

        Project project = e.getProject();
        VirtualFile newFile = LocalFileSystem.getInstance().findFileByIoFile(new File("D:\\code8\\Atelier\\src\\main\\java\\com\\atelier\\plugin\\pjavafx\\MyPackageChooserDialog.java"));

         FileEditor[] fileEditors = FileEditorManagerEx.getInstance(project).openFile(newFile, true);
         if(fileEditors!=null){
             for (FileEditor fileEditor : fileEditors) {
                 System.out.println(fileEditor.getName() + " is open");
             }
         }
         JComponent component = fileEditors[0].getComponent();
         component.show();

    }
}
